<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>用户详情</span>
      <el-button style="float: right; padding: 3px 0" type="text" @click="goback">返回</el-button>
    </div>
    <div class="text item">
      <p>姓名：{{ userinfo.name }}</p>
      <p>年龄：{{ userinfo.age }}</p>
      <p>头衔： {{ userinfo.position }}</p>
    </div>
  </el-card>
</template>

<script>
export default {
  name: 'UserInfo',
  props: ['id'],
  created() {
    this.getuserinfo()
  },
  data() {
    return {
      userinfo: {}
    }
  },
  methods: {
    async getuserinfo() {
      const { data:res } = await this.$http.get('/api/users/'+this.id)
      if(res.status !== 0)return this.$message.error('获取用户详情数据失败！')
      this.userinfo = res.data
      console.log(this.userinfo)
    },
    goback() {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="less" scoped>

</style>